﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace Swin_e_mon_Forms
{
    public class Inventory
    {
        private List<Item> _items = new List<Item>();

        public List<Item> Items
        {
            get { return _items; }
        }

        public void AddItem(Item value)
        {
            _items.Add(value);
        }

        public Item TakeItem(string id)
        {
            foreach (Item itm in _items)
            { 
                if (itm.IdentifiedBy(id))
                {
                    _items.Remove(itm);
                    return itm;
                }
            }
            return null;
        }

        public int _count
        {
            get { return _items.Count; }
        }

        public string ItemList
        {
            get
            {
                string result = "";

                foreach (Item itm in _items)
                    result += itm.Title + "\n";
                return result;
            }
        }

        public Item AccessItem(string id)
        {
            foreach (Item itm in _items)
            {
                if (itm.IdentifiedBy(id))
                {
                  return itm;
                }
            }
            return null;
        }
    }

    [TestFixture]
    public class InventoryTests
    {
        [Test]
        public void TestBasicFeatures()
        {
            Inventory inv = new Inventory();
            Item itm = new Item(new string[] {"Paper", "Parchment" },true);

            inv.AddItem(itm);

            Assert.AreEqual(1,inv._count, "FAILED");
            Assert.AreSame(itm, inv.TakeItem("Paper"));
            Assert.AreEqual(0, inv._count);
        }

       
    }
}
